   <%
layout("/layouts/platform.html"){
%>
<div class="panel-body" style="padding-top: 15px;">
	<div class="box">
		<div class="box-body">
			<div class="col-sm-12">
				<div class="row">
			        <table class="table table-bordered table-hover mg-t datatable">
		                <thead>
		                <tr>
		                    <th>用户名</th>
		                    <th>手机号</th>
		                    <th>推荐码</th>
		                    <th>总金额</th>
		                    <th>已提金额</th>
    	        	</table>
		        </div>
		    </div>
	    </div>
	</div>
</div>
<script language="JavaScript">
    var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": false,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/platform/sales/data",
                "type": "post",
                "data": function (d) {
                }
            },
            "columns": [
                {"data": "customer_id", "bSortable": true},
                {"data": "customer_id", "bSortable": true},
                {"data": "customer_id", "bSortable": true},
                {"data": "money", "bSortable": true},
                {"data": "out_money", "bSortable": true}
            ],
            "columnDefs": [
                {
                	"render": function (data, type, row) {
                		var customer=getCustomer(data);
                		if(null!=customer){
                			return customer.name;
                		}else{
                			return "";
                		}
                   	 },
                    "targets": 0
              	},
              	{
                	"render": function (data, type, row) {
                		var customer=getCustomer(data);
                		if(null !=customer){
                			return customer.mobile;
                		}else{
                			return "";
                		}
                   	 },
                    "targets": 1
              	}
              	,
              	{
                	"render": function (data, type, row) {
                		var customer=getCustomer(data);
                		if(null !=customer){
                			return customer.sale_code;
                		}else{
                			return "";
                		}
                   	 },
                    "targets": 2
              	}
            ]
            
        });
    }
    $(document).ready(function () {
        initDatatable();
    });
  	//获取客户
    function getCustomer(id){
  		var customer=null;
    	$.ajax({
    		url : "${base}/platform/sales/getCustomer",
    		data : {
    			id : id
    		},
    		type : "post",
    		async : false,
    		dataType : "json",
    		success : function(data){
    			customer=data;
    		},
    		error : function(XMLHttpRequest, textStatus, errorThrown) {
    			return false;
    		}
    	});
    	return customer;
    }

</script>
<%}%>
